// import $http from './httpRequest'
import {
  getStore
} from '@/util/store'
export function getDictLabel(type, value, defaultLabel) {
  if ((!value && value !== 0) || (!type && type !== 0)) {
    if (defaultLabel !== undefined) {
      return defaultLabel
    } else {
      return '--'
    }
  }
  let dictList = getStore({
    name: 'distList'
  })
  let dicts;
  for (let i = 0; i < dictList.length; i++) {
    if (dictList[i].code && dictList[i].code.toString() === type.toString()) {
      dicts = dictList[i]
    }
  }
  if (dicts.children) {
    for (let i = 0; i < dicts.children.length; i++) {
      if (dicts.children[i].dictKey && dicts.children[i].dictKey.toString() === value.toString()) {
        return dicts.children[i].dictValue
      }
    }
  }
  if (defaultLabel !== undefined) {
    return defaultLabel
  } else {
    return '--'
  }
}


export default {
  getDictLabel,
}
